﻿<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="Vote.ascx.cs" Inherits="SmsVotes.SmsVoting.Vote" %>
<%@ Register Src="../Header.ascx" TagName="Header" TagPrefix="uc1" %>
<%@ Register Src="../Footer.ascx" TagName="Footer" TagPrefix="uc1" %>

<script type="text/javascript">
    $(function() {
        $("#questionList").sortable();
    });

    function onSaveTemlateClick() {
        if ($get("questionList") != null) {
            $get("<%=hfQuestions.ClientID %>").value = $("#questionList").sortable("serialize");
        }
    }
</script>

<uc1:Header ID="Header" runat="server" />
<table class="PAGE" align="center" cellspacing="0" cellpadding="0">
    <tr valign="top">
        <td class="PAGE_BORDER_LEFT">
            <img src="images/body_left_bg.jpg" />
        </td>
        <td>
            <table cellpadding="0" cellspacing="0" border="0" width="100%">
                <tr>
                    <td class="TEXT_LEFT" valign="top">
                        <!-- TEXT -->
                        <table cellpadding="2" cellspacing="2" border="0" align="center">
                            <tr>
                                <td colspan="2" align="center">
                                    <asp:RequiredFieldValidator ID="rfvTemplate" runat="server" Display="Dynamic" ErrorMessage="Введите название голосования"
                                        ValidationGroup="vote" ControlToValidate="tbTemplate"></asp:RequiredFieldValidator>
                                </td>
                            </tr>
                            <tr>
                                <td align="right">
                                    Название голосования:
                                </td>
                                <td align="left">
                                    <asp:TextBox ID="tbTemplate" runat="server" />
                                </td>
                            </tr>
                            <tr>
                                <td colspan="2" align="center">
                                </td>
                            </tr>
                            <tr>
                                <td align="right">
                                    Выделенный номер
                                </td>
                                <td align="left">
                                    <asp:DropDownList ID="ddlSMSNumber" runat="server">
                                    </asp:DropDownList>
                                </td>
                            </tr>
                            <tr>
                                <td colspan="2" align="center">
                                    <asp:RequiredFieldValidator runat="server" ID="rfvVotesNumber" ControlToValidate="tbVotesNumber"
                                        ErrorMessage="Введите число" Display="Dynamic" ValidationGroup="vote"></asp:RequiredFieldValidator>
                                    <asp:RangeValidator ID="rvVotesNumber" runat="server" ControlToValidate="tbVotesNumber"
                                        ErrorMessage="Число введено неверно" Type="Integer" MinimumValue="0" ValidationGroup="vote"
                                        MaximumValue="99999" Display="Dynamic" CssClass="t"></asp:RangeValidator>
                                </td>
                            </tr>
                            <tr>
                                <td align="right">
                                    Сколько раз учитывается голос:<br />
                                    (0 – неограниченно)
                                </td>
                                <td align="left" valign="top">
                                    <asp:TextBox ID="tbVotesNumber" runat="server" Text="0" MaxLength="5" />
                                </td>
                            </tr>
                            <tr>
                                <td colspan="2" align="center">
                                </td>
                            </tr>
                            <tr>
                                <td align="right">
                                    <%= string.IsNullOrEmpty(Request.QueryString["vid"])?string.Empty:"Список вопросов:" %>
                                </td>
                                <td align="left">
                                    <asp:Panel ID="pQuestions" runat="server">
                                        <asp:ListView runat="server" ID="lvQuestions" OnItemCommand="lvQuestions_ItemCommand">
                                            <LayoutTemplate>
                                                <ul id="questionList" style="cursor: hand; cursor: pointer;">
                                                    <li id="itemPlaceholder" runat="server"></li>
                                                </ul>
                                            </LayoutTemplate>
                                            <ItemTemplate>
                                                <li id='question_<%# Eval("ID") %>'>
                                                    <%# Eval("Name") %><a href="?cmd=editquestion&qid=<%# Eval("ID") %>">Редактировать</a><asp:LinkButton
                                                        ID="lbtnDeleteQuestion" runat="server" Text="Удалить" OnClientClick="return confirm('Вы действительно хотите удалить вопрос?');"
                                                        CommandName="deletequestion" CausesValidation="false" CommandArgument='<%# Eval("ID") %>'></asp:LinkButton>
                                                </li>
                                            </ItemTemplate>
                                        </asp:ListView>
                                    </asp:Panel>
                                    <%= string.IsNullOrEmpty(Request.QueryString["vid"])?string.Empty: "<a href='?cmd=createquestion&vid="+Request.QueryString["vid"]+"'>Добавить вопрос</a>" %>
                                </td>
                            </tr>
                            <tr>
                                <td colspan="2" align="center">
                                </td>
                            </tr>
                            <tr>
                                <td colspan="2" align="center">
                                    С помощью перетаскивания вы можете менять порядок вопросов
                                </td>
                            </tr>
                            <tr>
                                <td colspan="2" align="center">
                                </td>
                            </tr>
                            <tr>
                                <td colspan="2" align="center">
                                    <asp:HiddenField ID="hfQuestions" runat="server" />
                                </td>
                            </tr>
                            <tr>
                                <td colspan="2" align="center">
                                    <asp:LinkButton ID="lbtnSaveTemplate" runat="server" Text="Сохранить" OnClick="lbtnCreateTemplate_Click"
                                        OnClientClick="onSaveTemlateClick();" ValidationGroup="vote"></asp:LinkButton>
                                </td>
                            </tr>
                            <tr>
                                <td colspan="2" align="center">
                                    <asp:LinkButton ID="lbtnCancel" runat="server" Text="Отменить" OnClick="lbtnCancel_Click"
                                        CausesValidation="false"></asp:LinkButton>
                                </td>
                            </tr>
                        </table>
                        <!-- TEXT -->
                    </td>
                    <td width="1" background="../images/splitter.jpg">
                        <img src="../images/splitter_top.jpg" alt="" />
                    </td>
                    <td class="TEXT_RIGHT" valign="top">
                        <!-- Navigation -->
                        <img src="../images/spacer2.gif" alt="" />
                    </td>
                </tr>
            </table>
        </td>
        <td class="PAGE_BORDER_RIGHT">
            <img src="images/body_right_bg.jpg">
        </td>
    </tr>
</table>
<uc1:Footer ID="Footer1" runat="server" />
